using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using Darilek.SandcastleExtensions.Utilities;

namespace Darilek.SandcastleExtensions.Components.Configuration
{
    public partial class KeywordsFilterConfigDlg : Form
    {
		private KeywordsFilterComponentConfiguration _settings;
		private string _configuration;

        public KeywordsFilterConfigDlg(string configuration)
        {
            InitializeComponent();

			_settings = ConfigurationSerializer.LoadConfiguration<KeywordsFilterComponentConfiguration>(configuration);
			SetMaxValue(_settings.MaxKeywordsCount);
        }

		public string Configuration
		{
			get { return _configuration; }
		}

        private void _TrackBar_Scroll(object sender, EventArgs e)
        {
            _Count.Text = _TrackBar.Value.ToString();
        }

        private void SetMaxValue(int i)
        {
            _TrackBar.Value = i;
            _TrackBar_Scroll(_TrackBar, null);
            _TrackBar.Update();
            _Count.Update();
        }

        private int GetMaxValue()
        {
            return _TrackBar.Value;
        }

        private void FilterKeywordsConfig_Load(object sender, EventArgs e)
        {
            _TrackBar_Scroll(_TrackBar, null);
        }

		private void _okButton_Click(object sender, EventArgs e)
		{
			_settings.MaxKeywordsCount = GetMaxValue();

			_configuration = ConfigurationSerializer.SaveConfiguration<KeywordsFilterComponentConfiguration>(_settings);

			this.Close();
		}
    }
}